import { defineConfig, loadEnv } from 'vite'
import UnoCSS from 'unocss/vite'
import react from '@vitejs/plugin-react'
import vue from '@vitejs/plugin-vue'
import { ViteMinifyPlugin as minify } from 'vite-plugin-minify'
import { ViteMpPlugin as mp } from 'vite-plugin-mp'
import {fileURLToPath} from "url";
export default defineConfig(({mode}) => {
  const env = loadEnv(mode, process.cwd() + '/env');
  console.log('env', process.cwd() + '/env')
  const { VITE_APP_CDN_URL } = env;
  console.log('VITE_APP_CDN_URL', VITE_APP_CDN_URL)
  return {
    base: VITE_APP_CDN_URL,
    plugins: [UnoCSS(), mp(), react(), vue(), minify()],
    envDir: '/env',
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    }
  }
})
